<template>
  <div class="content-box">
  
  <div style="flex:1">
    <router-view></router-view>
  <Invitation />
  </div>
  <div class="footer">
    <div class="footer-box">
      <div
        v-waves
        v-for="(item, index) in imgBox"
        :key="item"
        @click="handleSelectBottom(index)"
      >
        <img
          :src="getImageUrl(item + (activeItem === index ? '1' : '0'))"
          alt=""
        />
      </div>
    </div>
  </div>
  </div>
 
</template>
<script>
import { RouterView } from "vue-router";
import Invitation from "../components/Invitation.vue";

export default {
  components: {
    Invitation,
  },
  data() {
    return {
      imgBox: ["chonglang", "xiaolian", "geren"],
      activeItem: 0,
    };
  },
  methods: {
    getImageUrl(name) {
      return new URL(`../assets/imgs/home-${name}.png`, import.meta.url).href;
    },
    handleSelectBottom(index) {
      let obj = {
        0: "/surf",
        1: "/award",
        2: "/me",
      };
      obj[index] && this.$router.push(obj[index]);
      this.activeItem = index;
    },
  },
};
</script>

<style scoped>
.content-box{
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-x: hidden;
  padding-bottom: 1rem;
}
.footer {
  width:calc(100vw - 30vw);
  margin:0 auto;
  margin-top:1rem;
  /* z-index: 1; */
  /* position: fixed; */
  /* bottom: 2rem; */
  background: #fff;
  /* left: 50%; */
  /* transform: translateX(-50%); */
  border-radius: 6rem;
  box-shadow: 2px 2px 7px 0 rgb(0, 0, 0, 0.2);
  /* overflow: hidden; */
  user-select: none;
}

.footer-box {
  display: flex;
  justify-content: space-around;
  align-items: center;
  cursor: pointer;
}

.footer-box div {
  flex: 1;
  text-align: center;
  padding: 0.6rem 0;
}

.footer-box div:hover {
  background: #ccc;
}

.footer-box img {
  width: 2rem;
  height: auto;
  object-fit: contain;
}
</style>